﻿using System.Web.Mvc;
using System.Web.Routing;

namespace Zeenck
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            #region Ignore

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            #endregion Ignore

            #region Routes

            #region Profile

            routes.MapRoute(
                "My Profile",
                "profile",
                new { controller = "Profile", action = "Index", profileId = UrlParameter.Optional }
            );

            routes.MapRoute(
                "Edit Profile",
                "editprofile",
                new { controller = "Profile", action = "Edit" }
            );

            #endregion Profile

            #region Login / Logout

            routes.MapRoute(
                "Login",
                "login",
                new { controller = "Login", action = "Begin", ReturnUrl = UrlParameter.Optional }
            );

            routes.MapRoute(
                "LoginSubmit",
                "login/submit",
                new { controller = "Login", action = "Submit" }
            );

            routes.MapRoute(
                "Logout",
                "logout",
                new { controller = "Login", action = "Logout" }
            );

            #endregion Login / Logout

            #region Registration

            routes.MapRoute(
                "Registration",
                "registration",
                new { controller = "Registration", action = "Begin" }
            );

            routes.MapRoute(
                "RegistrationSubmit",
                "registration/submit",
                new { controller = "Registration", action = "Submit" }
            );

            routes.MapRoute(
                "RegistrationConfirmation",
                "registration/{confirmationCode}",
                new { controller = "Registration", action = "Confirmation", confirmationCode = UrlParameter.Optional }
            );

            routes.MapRoute(
                "CompleteRegistration",
                "completeregistration",
                new { controller = "Registration", action = "CompleteRegistration" }
            );

            routes.MapRoute(
                "FindInterests",
                "findinterests",
                new { controller = "Registration", action = "FindInterests", searchText = UrlParameter.Optional, maxResults = 5 }
            );

            #endregion Registration

            #region Reset Password

            routes.MapRoute(
                "VerifyEmailBegin",
                "resetpassword/verifyemail",
                new { controller = "ResetPassword", action = "VerifyEmailBegin" }
            );

            routes.MapRoute(
                "VerifyEmailSubmit",
                "resetpassword/verifyemail/submit",
                new { controller = "ResetPassword", action = "VerifyEmailSubmit" }
            );

            routes.MapRoute(
                "ResetPasswordBegin",
                "resetpassword/confirmation/{confirmationCode}",
                new { controller = "ResetPassword", action = "ResetPasswordBegin", confirmationCode = UrlParameter.Optional }
            );

            routes.MapRoute(
                "ResetPasswordSubmit",
                "resetpassword/confirmation/submit",
                new { controller = "ResetPassword", action = "ResetPasswordSubmit" }
            );

            #endregion Reset Password

            #region Home

            routes.MapRoute(
                "Home",
                "",
                new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                "About",
                "about",
                new { controller = "Home", action = "About" }
            );

            routes.MapRoute(
                "ContactUs",
                "contact",
                new { controller = "Home", action = "ContactUs" }
            );

            routes.MapRoute(
                "Help",
                "help",
                new { controller = "Home", action = "Help" }
            );

            routes.MapRoute(
                "AddInterestToProfile",
                "addinterest",
                new { controller = "Home", action = "AddInterest" }
            );

            #endregion Home

            #region Default

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "Root", // Route name
                "", // URL with parameters
                new { controller = "Home", action = "Index" } // Parameter defaults
            );


            #endregion Default

            #endregion Routes
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}